package com.muyaxuan.mail.controller.customer;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.muyaxuan.mail.dao.GoodsDao;
import com.muyaxuan.mail.dao.GoodsTypeDao;
import com.muyaxuan.mail.dao.OrderDao;
import com.muyaxuan.mail.dao.PicDao;
import com.muyaxuan.mail.dto.Goods;
import com.muyaxuan.mail.dto.GoodsType;
import com.muyaxuan.mail.dto.Picturcarousel;
@RequestMapping("/customer")
@Controller
public class HomeController {
	GoodsTypeDao goodsTypeDao = null;
	PicDao picDao = null;
	GoodsDao goodsDao = null;
	
	/**
	 * 跳转首页方法
	 * @return
	 */
	@RequestMapping("/home")
	public String home(final Model data){
		
		//商品类型dao
		goodsTypeDao = new GoodsTypeDao();
		//轮播图片dao
		picDao = new PicDao();
		//商品的图片dao
		goodsDao = new GoodsDao();
		//
	
		List<Goods> priceGoodsList = goodsDao.getGoodsByPirce();
		data.addAttribute("priceGoodsList", priceGoodsList);
		
	
	    //
	
		List<Goods> dateGoodsList = goodsDao.getGoodsByDate();
		data.addAttribute("dateGoodsList", dateGoodsList);
				
		
		//显示到首页的轮播图片
		List<Picturcarousel> picList = picDao.getPicList();
		//显示到首页的商品类型
		List<GoodsType> goodsTypeList = goodsTypeDao.getGoodTypeList();
		//将banner图片设置到响应数据中
		data.addAttribute("goodsTypeList", goodsTypeList);
		//将banner图片设置到响应数据中
		data.addAttribute("picList", picList);
		
		
		
		
		
		
		
		
		
		return "home";
				
	}
	@ResponseBody
	@RequestMapping("/priceGoodsAjax")
	public List<Goods> priceGoodsAjax(){
		goodsDao = new GoodsDao();
		List<Goods> goodsList = goodsDao.getGoodsByPirce();
		return goodsList;
	}
	
	

}
